package bai7.view;

import java.util.Scanner;

import bai7.service.EmployeeDAO;
import bai7.service.ProfileDAO;
import bai7.service.ProjectDAO;
import bai7.service.implement.EmployeeAPI;
import bai7.service.implement.ProfileAPI;
import bai7.service.implement.ProjectAPI;

public class Run {
	public static void thongtinEmployee(){
		EmployeeAPI app=new EmployeeDAO();
		Scanner ip=new Scanner(System.in);
		int choise=1;
		do{
			System.out.println("1.Them Employee");
			System.out.println("2.In danh sach");
			System.out.println("3.Xoa Employee");
			System.out.println("4.Tim Employee");

			int chon=Integer.parseInt(ip.nextLine());	

			switch(chon){
			case 1:app.inputEmployee();
			break;
			case 2:
				app.display();break;
			case 3:
				System.out.println("Nhap id can xoa");
				int id=Integer.parseInt(ip.nextLine());
				app.deleteEmployee(id);
				break;
			case 4:System.out.println("Nhap id can tim kiem");
			int id1=Integer.parseInt(ip.nextLine());
			app.searchEmployee(id1);
			break;
			default: System.out.println("NHap 1-4");

			}
		}
		while(choise==1);
	}
	public static void thongtinProfile(){
		ProfileAPI app=new ProfileDAO();
		Scanner ip=new Scanner(System.in);
		int choise=1;
		do{
			System.out.println("1.Them Profile");
			System.out.println("2.In danh sach Profile");
			System.out.println("3.Xoa Profile");
			System.out.println("4.Tim kiem Profile");
			int chon=Integer.parseInt(ip.nextLine());
			switch(chon){
			case 1:app.nhapProfile();;
			break;
			case 2:
				app.inProfile();
				break;
			case 3:
				System.out.println("Nhap id can xoa");
				int id=Integer.parseInt(ip.nextLine());
				app.deleteProfile(id);
				break;
			case 4:
				System.out.println("Nhap id can tim kiem");
				int id1=Integer.parseInt(ip.nextLine());
				app.deleteProfile(id1);
				break;
			}
		}while(choise==1);

	}
	public static void thongtinProject(){
		ProjectAPI app=new ProjectDAO();
		Scanner ip=new Scanner(System.in);
		int choise=1;
		do{
			System.out.println("1.Them Project");
			System.out.println("2.In danh sach Project");
			System.out.println("3.Xoa Project");
			System.out.println("4.Tim kiem Project");
			int chon=Integer.parseInt(ip.nextLine());
			switch(chon){
			case 1:app.inputProject();
			break;
			case 2:
				app.display();
				break;
			case 3:
				System.out.println("Nhap id can xoa");
				int id=Integer.parseInt(ip.nextLine());
				app.deleteProject(id);
				break;
			case 4:
				System.out.println("Nhap id can tim kiem");
				int id1=Integer.parseInt(ip.nextLine());
				app.searchProject(id1);
				break;
			}
		}while(choise==1);

	}
	public static void main(String args[]){
		Scanner ip=new Scanner(System.in);
		int choise=1;
		do{
			System.out.println("1.Thong tin Employee");
			System.out.println("2.Thong tin Project");
			System.out.println("3.Thong tin Profile");
			System.out.println("Chon chuc nang");
			try{
				int chon=Integer.parseInt(ip.nextLine());

				switch(chon){
				case 1:thongtinEmployee();
				break;
				case 2:
					thongtinProject();
					break;
				case 3:
					thongtinProfile();
					break;
				case 4:
					break;
				default: System.out.println("Nhap tu 1-4");
				}
			}catch(NumberFormatException e){
				System.out.println("Chua nhap hoac nhap sai dinh dang");
			}
		}while(choise==1);
	}
}
